package com.tedu.weibo.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一结果响应
 * 对应三个属性
 * int status
 * String msg
 * Object data
 */
@Data

@NoArgsConstructor
public class JsonResult {
    private Integer status;
    private String msg;
    private Object data;
    public JsonResult(StatusCode statusCode){
        this.status=statusCode.getStatusCode();
        this.msg=statusCode.getMessage();

    }
    public JsonResult(StatusCode statusCode,Object data){

        /*this.status=statusCode.getStatusCode();
        this.msg=statusCode.getMessage();*/
        this(statusCode);//调用本类的构造器

        this.data=data;
    }


    public static JsonResult success(Object data){
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }
    public static JsonResult success(){
        return success(null);
    }


}
